<template>
    <view class="container">
        <image class="avater section" :src="unit.avatar" mode="aspectFill"></image>
        <view class="content section">
            <article-content :article='unit.enArticle' :lightPointWord='false' :hidePointWord='true'
                @tapItem='tapItem'></article-content>
        </view>
        <view class="bottom">
            <view class="bottom fixed-bottom c-position_fixed c-flex_row">
                <view class="audio c-flex_1">
                    <audio-bar :src='unit.originalAudio' :ableDownloadPDF='true' @action='audioBarAction'></audio-bar>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
    import UnitDetailMixin from "../../mixins/unit-detail-mixin.js";
    import ContentMixin from "../../mixins/content-mixin.js";
    import articleContent from "../../components/article-content.vue";
    import audioBar from "../../components/audio-bar.vue";
    import {
        getPdfPath,
        downloadPDF
    } from "../../services/index.js"
    export default {
        components: {
            articleContent,
            audioBar
        },
        mixins: [UnitDetailMixin, ContentMixin],
        data() {
            return {

            }
        },
        methods: {
            tapItem(e) {
                console.log(e);
            },
            audioBarAction(e) {
                let type = e.type;
                if (type == 'pdf') {
                    getPdfPath(this.unit.id).then(res => {
                        downloadPDF(res)
                    })
                }
            }
        }
    }
</script>

<style lang="scss" scoped>
    @import "../../styles/sub-page.scss";
</style>